package com.itheima.dao;

import com.itheima.pojo.Student;
import jdk.internal.dynalink.linker.LinkerServices;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper {
    @Select("select * from s_student where id=#{id}")
    Student selectStudent(Integer id);
    @Update("update s_student set name=#{name},age=#{age} where\n" +
            "            id=#{id}")
    int updateStudent(Student student);
    @Insert("insert into s_student(id,name,age,cid)values(#{id},#{name},#{age},#{cid})")
    int insertStudent(Student student);
   /* @Delete("delect from s_student where id=#{id}")
    int deleteStudent(Integer id);*/
    //查询班级为?的学生，即一对多查询 cid为?的所有学生
    @Select("select * from s_student where cid=#{id}")
    @Results({@Result(id =true,column = "id", property = "id"),
              @Result(column = "name",property = "name"),
              @Result(column = "age",property = "age"),
              @Result(column = "cid",property = "cid"),
    })
    List<Student> selectAllStudentId(int cid);
}
